package mythread.demo001;

public class MyThread5 extends Thread {

    private int i=5;
    @Override
     synchronized //加锁的代码: 互斥区/临界区
      public void run() {
       super.run();;
           i--;//不用for，同步后其他线程没有机会
           System.out.println(Thread.currentThread().getName()+"-"+ i);
    }


}
